/**
 */
package ConnectorGenerator.DRD.impl;

import ConnectorGenerator.Auxiliary.impl.FirstClassEntityImpl;

import ConnectorGenerator.CommunicationStyle.CommunicationStyle;

import ConnectorGenerator.DRD.Connector;
import ConnectorGenerator.DRD.ConnectorEndpoint;
import ConnectorGenerator.DRD.DRDPackage;
import ConnectorGenerator.DRD.FeatureRequirement;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connector</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ConnectorGenerator.DRD.impl.ConnectorImpl#getCommunicationStyle <em>Communication Style</em>}</li>
 *   <li>{@link ConnectorGenerator.DRD.impl.ConnectorImpl#getEndpoints <em>Endpoints</em>}</li>
 *   <li>{@link ConnectorGenerator.DRD.impl.ConnectorImpl#getFeatureRequirements <em>Feature Requirements</em>}</li>
 *   <li>{@link ConnectorGenerator.DRD.impl.ConnectorImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConnectorImpl extends FirstClassEntityImpl implements Connector {
	/**
	 * The cached value of the '{@link #getCommunicationStyle() <em>Communication Style</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCommunicationStyle()
	 * @generated
	 * @ordered
	 */
	protected CommunicationStyle communicationStyle;

	/**
	 * The cached value of the '{@link #getEndpoints() <em>Endpoints</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEndpoints()
	 * @generated
	 * @ordered
	 */
	protected EList<ConnectorEndpoint> endpoints;

	/**
	 * The cached value of the '{@link #getFeatureRequirements() <em>Feature Requirements</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFeatureRequirements()
	 * @generated
	 * @ordered
	 */
	protected FeatureRequirement featureRequirements;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ConnectorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DRDPackage.Literals.CONNECTOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CommunicationStyle getCommunicationStyle() {
		if (communicationStyle != null && communicationStyle.eIsProxy()) {
			InternalEObject oldCommunicationStyle = (InternalEObject)communicationStyle;
			communicationStyle = (CommunicationStyle)eResolveProxy(oldCommunicationStyle);
			if (communicationStyle != oldCommunicationStyle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DRDPackage.CONNECTOR__COMMUNICATION_STYLE, oldCommunicationStyle, communicationStyle));
			}
		}
		return communicationStyle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CommunicationStyle basicGetCommunicationStyle() {
		return communicationStyle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCommunicationStyle(CommunicationStyle newCommunicationStyle) {
		CommunicationStyle oldCommunicationStyle = communicationStyle;
		communicationStyle = newCommunicationStyle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DRDPackage.CONNECTOR__COMMUNICATION_STYLE, oldCommunicationStyle, communicationStyle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ConnectorEndpoint> getEndpoints() {
		if (endpoints == null) {
			endpoints = new EObjectContainmentEList<ConnectorEndpoint>(ConnectorEndpoint.class, this, DRDPackage.CONNECTOR__ENDPOINTS);
		}
		return endpoints;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureRequirement getFeatureRequirements() {
		if (featureRequirements != null && featureRequirements.eIsProxy()) {
			InternalEObject oldFeatureRequirements = (InternalEObject)featureRequirements;
			featureRequirements = (FeatureRequirement)eResolveProxy(oldFeatureRequirements);
			if (featureRequirements != oldFeatureRequirements) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS, oldFeatureRequirements, featureRequirements));
			}
		}
		return featureRequirements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureRequirement basicGetFeatureRequirements() {
		return featureRequirements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFeatureRequirements(FeatureRequirement newFeatureRequirements) {
		FeatureRequirement oldFeatureRequirements = featureRequirements;
		featureRequirements = newFeatureRequirements;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS, oldFeatureRequirements, featureRequirements));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DRDPackage.CONNECTOR__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DRDPackage.CONNECTOR__ENDPOINTS:
				return ((InternalEList<?>)getEndpoints()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DRDPackage.CONNECTOR__COMMUNICATION_STYLE:
				if (resolve) return getCommunicationStyle();
				return basicGetCommunicationStyle();
			case DRDPackage.CONNECTOR__ENDPOINTS:
				return getEndpoints();
			case DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS:
				if (resolve) return getFeatureRequirements();
				return basicGetFeatureRequirements();
			case DRDPackage.CONNECTOR__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DRDPackage.CONNECTOR__COMMUNICATION_STYLE:
				setCommunicationStyle((CommunicationStyle)newValue);
				return;
			case DRDPackage.CONNECTOR__ENDPOINTS:
				getEndpoints().clear();
				getEndpoints().addAll((Collection<? extends ConnectorEndpoint>)newValue);
				return;
			case DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS:
				setFeatureRequirements((FeatureRequirement)newValue);
				return;
			case DRDPackage.CONNECTOR__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DRDPackage.CONNECTOR__COMMUNICATION_STYLE:
				setCommunicationStyle((CommunicationStyle)null);
				return;
			case DRDPackage.CONNECTOR__ENDPOINTS:
				getEndpoints().clear();
				return;
			case DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS:
				setFeatureRequirements((FeatureRequirement)null);
				return;
			case DRDPackage.CONNECTOR__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DRDPackage.CONNECTOR__COMMUNICATION_STYLE:
				return communicationStyle != null;
			case DRDPackage.CONNECTOR__ENDPOINTS:
				return endpoints != null && !endpoints.isEmpty();
			case DRDPackage.CONNECTOR__FEATURE_REQUIREMENTS:
				return featureRequirements != null;
			case DRDPackage.CONNECTOR__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //ConnectorImpl
